/obj/machinery/transformer
	name = "Roboticizer"
	desc = "A large metalic machine with an entrance and an exit. A sign on the side reads, 'human go in, robot come out', human must be lying down and alive."
	icon = 'icons/obj/recycling.dmi'
	icon_state = "roboticizer"
	layer = MOB_LAYER+1 // Overhead
	anchored = 1
	density = 1
	var/transform_dead = 0
	var/transform_standing = 0

/obj/machinery/transformer/New()
	// On us
	..()
	new /obj/machinery/conveyor(loc, WEST, 1)

/obj/machinery/transformer/Bumped(var/atom/movable/AM)
	// HasEntered didn't like people lying down.
	if(ishuman(AM))
		// Only humans can enter from the west side, while lying down.
		var/move_dir = get_dir(loc, AM.loc)
		var/mob/living/carbon/human/H = AM
		if((transform_standing || H.lying) && move_dir == EAST)// || move_dir == WEST)
			AM.loc = src.loc
			AM.anchored = 1
			do_transform(AM)

/obj/machinery/transformer/proc/do_transform(var/mob/living/carbon/human/H)
	if(stat & (BROKEN|NOPOWER))
		return
	if(!transform_dead && H.stat == DEAD)
		playsound(src.loc, 'sound/machines/buzz-sigh.ogg', 50, 0)
		return
	playsound(src.loc, 'sound/items/Welder.ogg', 50, 1)
	src.icon_state = "roboticizeron"
	H << "\red A Searing heat surrounds you as the machine locks itself!"
	sleep(30)
	playsound(src.loc, 'sound/items/bubblewrap.ogg', 50, 1)
	H << "\red A Claw comes out and snaps your arm out of it's socket!"
	H.emote("scream")
	H.adjustBruteLoss(10)
	sleep(40)
	playsound(src.loc, 'sound/weapons/pierce.ogg', 50, 1)
	H << "\red A mass of wires and devices drives itself into your skull! God, the pain! God... pain... guhhhhhh..."
	H.adjustBrainLoss(90)
	sleep(60)
	playsound(src.loc, 'sound/items/bubblewrap.ogg', 50, 1)
	H << "\red Your other arm is ripped out! Thankfully the drugs the brain device thingy is injecting nullified it!"
	H.emote("scream")
	H.adjustBruteLoss(5)
	sleep(80)
	playsound(src.loc, 'sound/machines/blender.ogg', 50, 1)
	H << "\red Your chest is being gored open by a cylindrical saw!"
	H.emote("scream")
	H.adjustBruteLoss(15)
	sleep(10)
	playsound(src.loc, 'sound/effects/splat.ogg', 50, 1)
	H << "\red Your chest splits open and your ribcage and everything in it is grinded into bloody mush!"
	H.emote("scream")
	sleep(50)
	playsound(src.loc, 'sound/effects/blobattack.ogg', 50, 1)
	H << "\red Your internal organs are being ripped out by a pair of sharp clawed hands!"
	H.emote("scream")
	sleep(20)
	playsound(src.loc, 'sound/effects/blobattack.ogg', 50, 1)
	sleep(20)
	playsound(src.loc, 'sound/effects/blobattack.ogg', 50, 1)
	sleep(20)
	playsound(src.loc, 'sound/weapons/circsawhit.ogg', 50, 1)
	playsound(src.loc, 'sound/weapons/circsawhit.ogg', 50, 1)
	H << "\red Your legs get sawn off by a single slice of a saw!"
	H.emote("scream")
	sleep(50)
	playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
	sleep(20)
	playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
	sleep(20)
	playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1)
	sleep(20)
	playsound(src.loc, 'sound/items/Welder.ogg', 50, 1)
	sleep(60)
	playsound(src.loc, 'sound/items/Welder2.ogg', 50, 1)
	sleep(80)
	src.icon_state = "roboticizer"
	use_power(5000) // Use a lot of power.
	var/mob/living/silicon/robot/R = H.Robotize()
	R.lying = 1
	R.module = new /obj/item/weapon/robot_module/hivebot(src)
	R.updatename("Prototype")
	R.icon_state = "hivebot"
	R.laws = new /datum/ai_laws/tyrant
	R.cell.maxcharge = 20000
	R.cell.charge = 20000
	spawn(50) // So he can't jump out the gate right away.
		playsound(src.loc, 'sound/machines/ping.ogg', 50, 0)
		new /obj/item/weapon/reagent_containers/food/snacks/ingredient/meat(src.loc)
		new /obj/item/weapon/reagent_containers/food/snacks/ingredient/meat(src.loc)
		new /obj/item/weapon/reagent_containers/food/snacks/ingredient/meat(src.loc)
		new /obj/item/weapon/reagent_containers/food/snacks/ingredient/meat(src.loc)
		new /obj/item/weapon/reagent_containers/food/snacks/ingredient/meat(src.loc)
		new /obj/item/weapon/reagent_containers/food/snacks/ingredient/meat(src.loc)
	del(src)


/obj/machinery/transformer/conveyor/New()
	..()
	var/turf/T = loc
	if(T)
		// Spawn Conveyour Belts

		//East
		var/turf/east = locate(T.x + 1, T.y, T.z)
		if(istype(east, /turf/simulated/floor))
			new /obj/machinery/conveyor(east, WEST, 1)

		// West
		var/turf/west = locate(T.x - 1, T.y, T.z)
		if(istype(west, /turf/simulated/floor))
			new /obj/machinery/conveyor(west, WEST, 1)